﻿using System;
using System.Collections.Generic;

using IDAL.AuthModel;
using Model.AuthModel;
using DALFactory.AuthModel;
namespace BLL.AuthModel
{
    /// <summary>
    /// 通用组件，权限模型，业务层，登录记录
    /// </summary>
    public class StaffLoginBLL
    {
        private IStaffLogin dal = DataAccess.CreateStaffLogin();

        /// <summary>
        /// 新增登录记录
        /// </summary>
        /// <param name="staff"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        public bool InsertStaffLogin(StaffInfo staff, string ip) 
        {
            StaffLoginInfo info = new StaffLoginInfo();
            info.Staff = staff;
            info.IP = ip;
            return dal.InsertStaffLogin(info);
        }

        /// <summary>
        /// 登录记录后台列表
        /// </summary>
        /// <param name="staffID"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public IList<StaffLoginInfo> BackList(int staffID, int pageIndex, int pageSize, out int recordCount) 
        {
            StaffLoginCondition condition = new StaffLoginCondition();
            condition.StaffID = staffID;
            condition.PageIndex = pageIndex;
            condition.PageSize = pageSize;
            condition.OrderBy = "AddTime DESC";
            return dal.ListStaffLogin(condition, out recordCount);
        }
    }
}
